class DeviceOrientation extends egret.DisplayObjectContainer{
	private label:egret.TextField;
	private bl;
	private arr_value;
	private value;
	private orientation;
	private sound:egret.Sound;
	private loadingUI: LoadingUI;
	public constructor() {
		super();
		this.bl=true;
		this.arr_value=new Array();
	


		this.label=new egret.TextField();
		this.label.y=50;
		this.label.x=50;
		// this.addChild(this.label);

		this.sound=RES.getRes("shake_mp3");


	}
	public CanShake(){
		this.orientation=new egret.DeviceOrientation();
		this.orientation.addEventListener(egret.Event.CHANGE,this.onOrientation,this);
		this.orientation.start();
	}
	public Reset(){
		this.bl=true;
	}

	private onOrientation(e:egret.OrientationEvent){
		if(this.bl){
			this.arr_value.push(e.alpha);
			this.arr_value.push(e.beta);
			this.arr_value.push(e.gamma);
			this.value=e.gamma;
			this.bl=false;
		}
		if(e.gamma-this.value>30||e.gamma-this.value<-30){
			console.log("Begin_draw");
			this.orientation.removeEventListener(egret.Event.CHANGE,this.onOrientation,this);
			this.dispatchEvent(new LoadEvent("Begin_Draw"));
			this.sound.type=egret.Sound.EFFECT;
			this.sound.play();
			// ShakeSound();			
		}

		// this.label.text="方向:nalpha:"+e.alpha+",nbeta:"+e.beta+",ngamma:"+e.gamma;
		this.label.text="ngamma:"+e.gamma+"bala"+this.value;
	}
}
declare function ShakeSound()